package pers.qianyu.month_202101.date_20210123;

/**
 * 153. 寻找旋转排序数组中的最小值
 * https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/
 *
 * @author mizzle rain
 * @date 2021-01-23 17:23
 */
public class FindMin {
    public int findMin(int[] nums) {
        int len = nums.length;
        int left = 0, right = len - 1, target = nums[len - 1];
        while (left < right) {
            int mid = (left + right) >> 1;
            if (nums[mid] <= target) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return nums[left];
    }
}
